package dataManagement.action;

import java.io.IOException;
import javax.xml.parsers.ParserConfigurationException;
import org.xml.sax.SAXException;
import dataImport.action.helper.XMLReader;
import dataImport.action.manager.EntityReaderManager;
import dataImport.exception.InstanceAlreadyCreatedException;
import dataImport.exception.MissingReader;
import dataImport.exception.ReaderAlreadyFixedException;
import dataManagement.action.helper.UserDataCommunication;
import dataManagement.action.manager.ActionManager;
import dataManagement.exception.ActionCouldNotBeExecuted;


public class Main {

	public static void main(String[] args) throws MissingReader, ParserConfigurationException, SAXException, ReaderAlreadyFixedException {

		try {
			XMLReader.createInstance("game.properties");
		}
		catch (IOException | InstanceAlreadyCreatedException e) {
			e.printStackTrace();
		}

		EntityReaderManager entityReaderManager = new EntityReaderManager();
		entityReaderManager.read();

		ActionManager actionManager = new ActionManager(entityReaderManager);

		while (true) {
			String command = UserDataCommunication.read();

			try {
				actionManager.execute(command);
			}
			catch (ActionCouldNotBeExecuted e) {
				System.out.println("Cannot execute this action");
			}
		}
	}

}
